#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

double champagneTower(int poured, int query_row, int query_glass) {
    vector<double> row = { (double)poured };
    for (int i = 1; i <= query_row; i++)
    {
        vector<double> nextrow(i + 1, 0.0);
        for (int j = 0; j < row.size(); j++)
        {
            double volume = row[j];
            if (volume > 1)
            {
                nextrow[j] += (volume - 1) / 2;
                nextrow[j + 1] += (volume - 1) / 2;
            }
        }
        row = nextrow;
    }
    return min(1.0, row[query_glass]);
}

bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) {
    return !(rec1[2] <= rec2[0] ||   // left
        rec1[3] <= rec2[1] ||   // bottom
        rec1[0] >= rec2[2] ||   // right
        rec1[1] >= rec2[3]);    // top
}
